package com.business.corp;

import java.util.Date;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.beanutils.ConvertUtils;

import com.frame.struts.ActionContext;
import com.frame.struts.BaseBean;
import com.utils.CommUtil;
import com.utils.DateConverter;

public class ScxkForm extends BaseBean
{
    public ScxkForm()
    {
    }
    
    static{
        ConvertUtils.register(new DateConverter(), Date.class);
    }

    ScxkEntity scxkEntity = new ScxkEntity();
    private String oldId="";

    public String addScxk()
    {
        if( logger.isDebugEnabled() )
        {
            logger.debug( "enter addScxk()" );
        }
        HttpServletRequest request = ActionContext.getActionContext()
                                                  .getRequest();
        HttpServletResponse response = ActionContext.getActionContext()
                                                    .getResponse();
        NewCorpFactory factory = NewCorpFactory.getInstance();
        String qyid = (String) request.getSession()
                                      .getAttribute( "session_qyid" );
        scxkEntity.setQyid( qyid );
        scxkEntity.setOptdate( new Date() );
        scxkEntity.setOptrid( CommUtil.getUserId( request ) );
        scxkEntity.setXh( NewCorpFactory.getNextXh( "qy_zjjl_scxk", qyid ) );
        try
        {
            if( factory.addScxk( scxkEntity ) )
            {
                System.out.println( "Enter addscxk()" );
                response.sendRedirect( "/corp/queryscxk.jsp" );
            }else{
                response.sendRedirect( "/failed.jsp" );
            }
        }
        catch( Exception e )
        {
        }
        return null;

    }

    public String editScxk()
    {
        if( logger.isDebugEnabled() )
        {
            logger.debug( "enter addScxk()" );
        }
        HttpServletRequest request = ActionContext.getActionContext()
                                                  .getRequest();
        HttpServletResponse response = ActionContext.getActionContext()
                                                    .getResponse();
        NewCorpFactory factory = NewCorpFactory.getInstance();
        String qyid = (String) request.getSession()
                                      .getAttribute( "session_qyid" );
        scxkEntity.setQyid( qyid );
        scxkEntity.setOptdate( new Date() );
        scxkEntity.setOptrid( CommUtil.getUserId( request ) );
        factory.delScxk(qyid,scxkEntity.getXh());
        try
        {
            if( factory.addScxk( scxkEntity ) )
            {
                System.out.println( "Enter editscxk()" );
                response.sendRedirect( "/corp/queryscxk.jsp" );
            }else{
                response.sendRedirect( "/failed.jsp" );
            }
        }
        catch( Exception e )
        {
            e.printStackTrace();
        }
        return null;
    }
	
    public String getQyid() {
		return scxkEntity.getQyid();
	}
	public void setQyid(String qyid) {
		scxkEntity.setQyid(qyid);
	}
	public int getXh() {
		return scxkEntity.getXh();
	}
	public void setXh(int xh) {
		scxkEntity.setXh(xh);
	}
	public String getCpmc() {
		return scxkEntity.getCpmc();
	}
	public void setCpmc(String cpmc) {
		scxkEntity.setCpmc(cpmc);
	}
	public String getCpxh() {
		return scxkEntity.getCpxh();
	}
	public void setCpxh(String cpxh) {
		scxkEntity.setCpxh(cpxh);
	}
	public String getZsmc() {
		return scxkEntity.getZsmc();
	}
	public void setZsmc(String zsmc) {
		scxkEntity.setZsmc(zsmc);
	}
	public String getZsbh() {
		return scxkEntity.getZsbh();
	}
	public void setZsbh(String zsbh) {
		scxkEntity.setZsbh(zsbh);
	}
	public String getYxq() {
		return scxkEntity.getYxq();
	}
	public void setYxq(String yxq) {
		scxkEntity.setYxq(yxq);
	}
	public String getSfxzsc() {
		return scxkEntity.getSfxzsc();
	}
	public void setSfxzsc(String sfxzsc) {
		scxkEntity.setSfxzsc(sfxzsc);
	}
	public String getFzjg() {
		return scxkEntity.getFzjg();
	}
	public void setFzjg(String fzjg) {
		scxkEntity.setFzjg(fzjg);
	}
	public String getOptrid() {
		return scxkEntity.getOptrid();
	}
	public void setOptrid(String optrid) {
		scxkEntity.setOptrid(optrid);
	}
	public Date getOptdate() {
		return scxkEntity.getOptdate();
	}
	public void setOptdate(Date optdate) {
		scxkEntity.setOptdate(optdate);
	}
	public String getRecstate() {
		return scxkEntity.getRecstate();
	}
	public void setRecstate(String recstate) {
		scxkEntity.setRecstate(recstate);
	}
	public String getRemark() {
		return scxkEntity.getRemark();
	}
	public void setRemark(String remark) {
		scxkEntity.setRemark(remark);
	}

}
